package threadMethod;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author： pang-yun
 * @date： 2021-10-14 10:26
 * 功能目的 ：用于
 */

@Slf4j
public class Park {

    public static void main(String[] args) throws InterruptedException {
        parkInterrupt();


    }

    private static void parkInterrupt() throws InterruptedException {
        Thread park = new Thread(() -> {
            log.info("park.....");
            LockSupport.park();
            log.info("unpark....");
            log.info("打断状态: {}",Thread.interrupted());
            LockSupport.park();
            log.info("repeated park....");
        }, "park");

        park.start();

        TimeUnit.SECONDS.sleep(2);

        park.interrupt();
    }
}
